package cn.chencaiju.exam;

import org.junit.Test;

public class DayGet {
	public static int getDays(int year, int month) {
		if(month>12||month<1)return -1;
		int day=30;
		boolean isLeap=false;
		if(year%400==0||(year%100!=0&&year%4==0)) {
			isLeap=true;
		}else {
			isLeap=false;
		}
		switch(month) {
		case 2:
			if(isLeap)
				day=29;
			else
				day=28;
			break;
		case 4: case 6: case 9: case 11:
			day=30;break;
		default:
			day=31;
		}
		return day;
	}
	@Test public void testGetDays() {
		System.out.println(getDays(1996,2));
	}
}
